﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLCONGNOLIBS.Models.DungDD_Models;
using QLCONGNOLIBS.Securities.DungDD_SecurityFramework;

namespace QLCONGNOLIBS.Controllers.DungDD_Controller
{
    public class IDepartment_Controller_DungDD
    {
        // datafield
        private SqlConnection objConnection_g;
        private tblUser_SC objUserSc_g;
        private IDepartment_Model_DungDD objDepartmentModel_g;
        // constructor
        public IDepartment_Controller_DungDD()
        {

        }

        public IDepartment_Controller_DungDD(SqlConnection objConnectionPara, tblUser_SC objUserPara)
        {
            objConnection_g = objConnectionPara;
            objUserSc_g = objUserPara;
            objDepartmentModel_g = new IDepartment_Model_DungDD(objConnection_g, objUserSc_g);
        }
        public DataTable GetDepartmentDataTable(string ttphongban)
        {
            if (ttphongban.Equals("notset"))
            {
                return objDepartmentModel_g.GetDepartment_NotSet();
            }
            else if (ttphongban.Equals("deleted"))
            {
                return objDepartmentModel_g.GetDepartment_deleted();
            }
            else
            {
                return objDepartmentModel_g.GetDepartment_All();
            }

        }
        public bool IsDuplicate_DepartmentName(string dname)
        {
            return objDepartmentModel_g.IsDuplicate_DepartmentName_M(dname);
        }

        public bool Insert_Update_Department_C(IDepartment_Entity objEntity)
        {
            return objDepartmentModel_g.Insert_Update_Department_m(objEntity);
        }

        public bool UpdateDepartmentStatus_ByID_C(Guid idp, bool isDeleted)
        {
            return objDepartmentModel_g.UpdateDepartmentStatus_ByID_m(idp, isDeleted);
        }

        public bool DeleteDepartment_ByID_C(Guid objGuidc)
        {
            return objDepartmentModel_g.DeleteDepartment_ByID_m(objGuidc);
        }
        public bool Update_note_department_C(Guid departmentID, string note)
        {
            return objDepartmentModel_g.Update_note_department_m(departmentID, note);
        }

    }
}
